package com.mark.springsecurity.dto.req;

import com.mark.springsecurity.domain.SysRole;
import lombok.Data;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;

@Data
public class SysRoleQueryQbj {
    private String name;

    public static Example<SysRole> buildExample(SysRoleQueryQbj sysRoleQueryQbj) {
        ExampleMatcher matcher = ExampleMatcher.matching()
                .withIgnoreCase("name")
                .withIgnoreNullValues()
                .withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains());

        return Example.of(SysRole.builder()
                .name(sysRoleQueryQbj.getName())
                .enabled(Boolean.TRUE)
                .build(), matcher);
    }
}
